package com.btex.app.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.btex.app.R;
import com.btex.app.entity.OTCPaymentMethosdInfo;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * @author zy zhangyi <zhangyi, 1104745049@QQ.com
 * @version v1.0
 * @project study1
 * @Description
 * @encoding UTF-8
 * @date 2018/8/19
 * @time 下午9:00
 * @修改记录 <pre>
 * 版本       修改人         修改时间         修改内容描述
 * --------------------------------------------------
 * <p>
 * --------------------------------------------------
 * </pre>
 */

public class OTCPaymentMethodsAdapter extends BaseQuickAdapter<OTCPaymentMethosdInfo.DataBean, BaseViewHolder> {
    private Context mContext;

    public OTCPaymentMethodsAdapter(@Nullable List<OTCPaymentMethosdInfo.DataBean> data, Context context) {
        super(R.layout.otc_payment_methods_item, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OTCPaymentMethosdInfo.DataBean item) {


        helper.addOnClickListener(R.id.otc_Payment_methods_tv_bank_imag);
        TextView otc_Payment_methods_tv_add = (TextView) helper.getView(R.id.otc_Payment_methods_tv_add);
        TextView otc_Payment_methods_tv_number = (TextView) helper.getView(R.id.otc_Payment_methods_tv_number);
        TextView otc_Payment_methods_tv_bank_name = (TextView) helper.getView(R.id.otc_Payment_methods_tv_bank_name);
        ImageView otc_Payment_methods_tv_bank_imag = (ImageView) helper.getView(R.id.otc_Payment_methods_tv_bank_imag);
        ImageView otc_Payment_methods_imag = (ImageView) helper.getView(R.id.otc_Payment_methods_imag);


        String type = item.getType();
        if (type.equals("alipay")) {
            otc_Payment_methods_tv_bank_name.setVisibility(View.GONE);
            otc_Payment_methods_tv_bank_imag.setVisibility(View.VISIBLE);
            otc_Payment_methods_imag.setBackground(mContext.getResources().getDrawable(R.mipmap.otc_zhi));
            otc_Payment_methods_tv_add.setText("支付宝");
        } else if (type.equals("weixin")) {
            otc_Payment_methods_tv_bank_name.setVisibility(View.GONE);
            otc_Payment_methods_tv_bank_imag.setVisibility(View.VISIBLE);
            otc_Payment_methods_imag.setBackground(mContext.getResources().getDrawable(R.mipmap.otc_weixin));
            otc_Payment_methods_tv_add.setText("微信");
        } else if (type.equals("tianya")) {

            otc_Payment_methods_tv_bank_name.setText(item.getBank());
            otc_Payment_methods_tv_bank_imag.setVisibility(View.VISIBLE);
            otc_Payment_methods_tv_add.setText("天涯");
            otc_Payment_methods_imag.setBackground(mContext.getResources().getDrawable(R.mipmap.tian_ya));

        } else {
            otc_Payment_methods_tv_bank_name.setText(item.getBank());
            otc_Payment_methods_tv_bank_imag.setVisibility(View.GONE);
            otc_Payment_methods_tv_add.setText("银行卡");
            otc_Payment_methods_imag.setBackground(mContext.getResources().getDrawable(R.mipmap.otc_bank));
        }

        otc_Payment_methods_tv_number.setText(item.getCard_no());


    }
}
